<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title th:text="${name}"></title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f8f9fa;
        }
        #imageContainer {
            border: 1px solid #ccc;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            background-color: #fff;
            overflow: auto; /* Allow scrolling if the image is larger than the container */
        }
        #imageContainer img {
            display: block;
            width: auto;
            height: auto;
        }
    </style>


</head>
<body>
<div id="imageContainer">
    <img id="displayedImage" alt="Original Size Image" />
</div>
</body>
<script type="text/javascript" language="javascript" th:inline="javascript">
    //获取url上面的参数
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return (false);
    }

    let token = getQueryVariable("token");
    let url = [[${url}]]+"?token="+token;
    url = url.replace("\\", "");

    // 获取img元素
    var imgElement = document.getElementById('displayedImage');

    // 设置img元素的src属性
    imgElement.src = url; // 替换为你的图片URL

    // 当图片加载完成时，调整容器大小
    imgElement.onload = function() {
        imgElement.style.width = imgElement.naturalWidth + 'px';
        imgElement.style.height = imgElement.naturalHeight + 'px';
    }

</script>

</html>